<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
        <meta name="author" content="order by dede58.com"/>
		<title>注册</title>
		<link rel="stylesheet" href="{__STATIC_PATH__}index/login/css/reset.css" />
		<link rel="stylesheet" href="{__STATIC_PATH__}index/login/css/common.css" />
		<link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css">
		<script type="text/javascript" src="/static/layui/layui.js"></script>
		<script type="text/javascript" src="/static/index/js/jquery.min.js"></script>
	</head>
	<body>
		<div class="wrap login_wrap">
			<div class="content">
				<div class="logo"></div>
				<div class="login_box">
					<div class="login_form">
						<div class="login_title">
							注册
						</div>
						<form class="layui-form">
							<div class="form_text_ipt">
								<input name="username" type="text" id="username" class="layui-input" placeholder="手机号/邮箱">
							</div>
							<div class="form_text_ipt">
								<input name="password" type="password" id="password" class="layui-input" placeholder="密码">
							</div>
							<div class="form_text_ipt">
								<input name="repassword" type="password" id="repassword" class="layui-input" placeholder="重复密码">
							</div>
							
							<div class="form_btn">
								<button type="button" onclick="register()">注册</button>
							</div>
							<div class="form_reg_btn">
								<span>已有帐号？</span><a href="/index/user/login">马上登录</a>
							</div>
						</form>
						<div class="other_login">
							<div class="left other_left">
								<span>其它登录方式</span>
							</div>
							<div class="right other_right">
								<a href="#">QQ登录</a>
								<a href="#">微信登录</a>
								<a href="#">微博登录</a>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script type="text/javascript">
			layui.use(['layer'],function(){
				$ = layui.jquery;
				layer = layui.layer;
				// 用户名控件获取焦点
				$('#username').focus();
				// 回车登录
				$('input').keydown(function(e){
					if(e.keyCode == 13){
						register();
					}
				});
			});
			function register(){
				var username = $.trim($('#username').val());
				var pwd = $.trim($('#password').val());
				var repwd = $.trim($('#repassword').val());
				console.log(username,pwd)
				if(username == ''){
					layer.alert('请输入用户名',{icon:2});
					return;
				}
				if(pwd == ''){
					layer.alert('请输入密码',{icon:2});
					return;
				}
				if (repwd == ''){
					layer.alert('请再次输入密码',{icon:2});
					return;
				}else if (pwd != repwd){
					layer.alert('密码输入不一致',{icon:2});
					return;
				}
				$.post('/index/user/register',{'username':username,'password':pwd},function(res){
					if(res.code>0){
						layer.alert(res.msg,{icon:2});
					}else{
						layer.msg(res.msg);
						setTimeout(function(){window.location.href = '/index/user/login'},1000);
					}
				},'json');
			}
		</script>
	</body>
</html>
